<template>
  <span class="xtx-checkbox" :class="{'checked':checked }" @click="changeChecked">
    <i v-if="checked" class="iconfont icon-checked"></i>
    <i v-else class="iconfont icon-unchecked"></i>
    <span v-if="$slots.default"><slot /></span>
  </span>
</template>
<script>
import { useVModel } from '@vueuse/core'
export default {
  props: {
    mode: {
      type: Boolean,
      default: false
    }
  },
  emits: ['abc'],
  name: 'XtxCheckbox',
  setup (props, { emit }) {
    const checked = useVModel(props, 'mode', emit)

    const changeChecked = () => {
      checked.value = !checked.value
      emit('abc', checked)
    }

    return { changeChecked, checked }
  }
}
</script>
<style lang="less" scoped>
.icon-checked,.checked{
color: @xtxColor;
}
</style>
